package ch5;

public class Teacher {
	private String name;
	private int age;

	public Teacher() {
	}

	private Teacher(String name) {
		this.name = name;
	}

	public Teacher(String name, int age) {
		// super();
		// this.name = name;
		this(name);

		this.setAge(age);
		// if (age < 22) {
		// System.err.println("年龄“" + age + "”不合适");
		// age = 22;
		// }
		// this.age = age;
	}

	// 修改
	public void setName(String n) {
		this.name = n;
	}

	public void setAge(int a) {
		if (a < 22) {
			System.err.println("年龄“" + a + "”不合适");
			a = 22;
		}
		this.age = a;
	}

	public String getName() {
		return this.name;
	}

	public int getAge() {
		return this.age;
	}

	public void happyBirthday() {
		System.out.println(name + ",生日快乐");
		increaseAge();
	}

	private void increaseAge() {
		age++;
	}

	public void selfIntro() {
		System.out.println("大家就好，我叫" + name + "，今年" + age + "岁了");
	}
}
